﻿
function GetAddComment(taskID) {
    $.post('Task/GetAddComment/', { taskid: taskID }, function (result) {
        $('.AddComment-wrapper').html(result);
        var window = $('#AddComment').data('tWindow');
        window.center().open();
    });
}

function AddComment(){
    var hasError = false;
    $('.dialogue-AddComment form textarea').removeClass('fieldError');

    String.prototype.isEmpty = function () { return /^\s*$/.test(this); }

    $content = $('.dialogue-AddComment form #Contents');
    if ($content.val().length == 0) {
        $content.addClass('fieldError');
        hasError = true;
    }

    if (hasError) {
        return;
    } else {
        var query = $('.dialogue-AddComment form').serializeArray();
        $.post('Task/AddComment', query, function (result) {
            if (result.commentAdd) {
                $('#AddComment').data('tWindow').close();
            } else {
                alert('添加评论失败');
            }
        });
    }
}

function CancelAddComment() {
    var window = $('#AddComment').data('tWindow');
    window.close();
}
